export default {
	data() {
		return {
			iconColor: "#383838",
			num:0,
			userIn:null
		}
	},
	onLoad(){
		if(this.$store.state.userIn){
			this.userIn = JSON.parse(this.$store.state.userIn)
		}
	},
	methods: {
		async Collection() {
			if (this.$store.state.token) {
				let params = {
					ak: this.$store.state.token,
					cmd: 'mMemFav_list',
					para: {
						stype: this.stype,
						spageid: this.spageid,
						skeyid: this.id,
						title: this.title
					}
				}
				// const res = await this.$u.api.getDram(params)
				// console.log(res)
				// if (res.Data.Data.length > 0) {
				// 	this.iconColor = "#c40200"
				// } else {
				// 	this.iconColor = "#383838"
				// }
			}

		},
		async GoCollection(spageid,skeyid,title,img) {
			if (!this.$store.state.token) {
				this.$u.route('/pages/myuser/user/UserInfo')
			} else {
				let params = {
					ak: this.$store.state.token,
					cmd: 'mMemFav_add0_proc',
					para: {
						spageid: spageid,
						skeyid: skeyid,
						title: title,
						img: img,
						_creatememid: this.userIn.id,
						_appid: this.userIn._appid
					}
				}
				const res = await this.$u.api.getDram(params)
				console.log(res)
				if (res.Data.id != 1) {
					this.iconColor = "#c40200"
					this.num = 1
				} else {
					this.iconColor = "#383838"
					this.num = -1
				}
			}
		}
	}
}
